package com.yh.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yh.bean.BuyGoods;
import com.yh.bean.User;
import com.yh.dao.BuyGoodsDao;
import com.yh.service.BuyGoodsService;


@Service
public class BuyGoodsServiceImpl implements BuyGoodsService {
	
	@Autowired
	private BuyGoodsDao buyGoodsDao;
	
	//删除订单
	@Override
	public void deleteBuyGoods(BuyGoods buyGoods) {
		// TODO Auto-generated method stub
		buyGoodsDao.deleteBuyGoods(buyGoods);
		System.out.println("=======删除订单=======");
	}
	
	//添加订单
	@Override
	public int addBuyGoods() {
		// TODO Auto-generated method stub
		BuyGoods buyGoods=new BuyGoods();
		buyGoods.setBphoto("火麒麟.png");
		buyGoods.setBprice(998);
		buyGoods.setBsum(3);
		buyGoods.setBtime("2017-12-15");
		buyGoods.setGdetail("火麒麟");
		buyGoods.setU_id(3);
		System.out.println("========添加订单============");
		return buyGoodsDao.addBuyGoods(buyGoods);
	}
	
	//查询显示订单列表
	@Override
	public List<BuyGoods> listBuyGoods() {
		// TODO Auto-generated method stub
		BuyGoods buyGoods=new BuyGoods();
		buyGoods.setU_id(7);
		System.out.println("========显示订单列表============");
		return buyGoodsDao.listBuyGoods(buyGoods);
	}
	
	//根据商品ID添加订单
	@Override
	public int addBuyGoodsByGoods(BuyGoods buyGoods) {
		// TODO Auto-generated method stub
		return buyGoodsDao.addBuyGoodsByGoods(buyGoods);
	}
	
	//根据用户ID查询用户信息
	@Override
	public User queryUser(User user) {
		// TODO Auto-generated method stub
		return buyGoodsDao.queryUser(user);
	}
	
	//修改用户余额
	@Override
	public void updateUserMoney(User user) {
		// TODO Auto-generated method stub
		buyGoodsDao.updateUserMoney(user);
	}
	
	//增加用户积分
	@Override
	public void increaseUserIntegral(User user) {
		// TODO Auto-generated method stub
		buyGoodsDao.increaseUserIntegral(user);
	}

}
